package cn.gqr.mapper;

import cn.gqr.entity.Role;
import cn.gqr.entity.User;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    String wqSql = "${ew}";

    @Select("select * from t_user as u where u.account = #{username}")
    User selectUserInfoByUsername(@Param("username") String username);

    //根据用户id查询角色
    List<Role> selectUserRole(@Param("userId") Integer userId);

    //根据角色id查询权限
    List<String> selectUserPermissions(@Param("roleId") Integer roleId);

    //修改用户名称以及电话
    int updateNicknameOrPhone(@Param("nickname") String nickname, @Param("phone")String phone , @Param("uid") int uid);

    //查询所有的买家用户
    List<User> queryAllUsers(@Param("start") int start, @Param("num")int num);

    //所有的买家用户总数
    Integer queryAllUsersTotal();

    //添加管理员角色
    int insertAdminRole(@Param("userId")Integer userId);

    //添加普通用户角色
    int insertUserRole(@Param("userId")Integer userId);

}
